{extend name="admin@public/main"}

{block name="search"}
<div class="layui-row">
    <form class="layui-form layui-col-md12 x-so" method="get" action="{:url($Request.path)}">
        <div class="layui-input-inline">
            <select name="cid">
                <option value="">请选择所属分类</option>
                <option value="0" {eq name="$Request.get.cid" value="0"}selected{/eq}>未指定分类</option>
                {volist name="cates" id="c"}
                <option value="{$c.id}" {eq name="$Request.get.cid" value="$c.id"}selected{/eq}>{$c._pre}{$c.title}</option>
                {/volist}
            </select>
        </div>
        <div class="layui-input-inline">
        <input type="text" name="title" value="{$Request.get.title}" placeholder="请输入文章名（支持模糊搜索）" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-input-inline">
            <select name="state">
                <option value="">请选择文章状态</option>
                <option value="0" {eq name="$Request.get.state" value="0"}selected{/eq}>已禁用</option>
                <option value="1" {eq name="$Request.get.state" value="1"}selected{/eq}>已启用</option>
                {/volist}
            </select>
        </div>
        <button class="layui-btn layui-btn-sm"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
    </form>
</div>
{/block}

{block name="button"}
<xblock>
    {if auth("$classuri/add")}
    <button class="layui-btn layui-btn-xs" data-modal='{:url("$classuri/add")}?cid={$Request.get.cid}' data-reload="true" data-title="添加文章">
        <i class="layui-icon"></i>添加文章
    </button>
    {/if}
    <span class="x-right" style="line-height:40px"></span>
</xblock>
{/block}

{block name="table"}
<table class="layui-table">
    <thead>
    <tr>
        <th width="10">id</th>
        <th width="50">所属分类</th>
        <th width="50">标题</th>
        <th width="50">缩略图</th>
        <th width="50">关键词</th>
        <th width="100">描述</th>
        <th width="100">状态</th>
        <th width="100">更新时间</th>
        <th width="100">操作</th>
    </tr>
    </thead>
    <tbody>
    {volist name="list" id="vo"}
    <tr>
        <td>{$vo.id}</td>
        <td>{$vo.ctitle|default="未指定分类"}</td>
        <td>{$vo.title}</td>
        <td>{:$vo.thumb?"<a href='".$vo.thumb."' target='_blank'>查看</a>":"无"}</td>
        <td>{$vo.keyword}</td>
        <td>{$vo.description}</td>
        <td>{:$vo.state?'已启用':'已禁用'}</td>
        <td>{$vo.update_time|date='Y-m-d H:i'}</td>
        <td>
            {if auth("$classuri/edit")}
            <button class="layui-btn layui-btn-xs" href="javascript:;" data-reload="true" data-title="编辑文章" data-modal='{:url("$classuri/edit")}?id={$vo.id}&cid=2'>
                编辑
            </button>
            {/if}
            {if auth("$classuri/change")}
            <button class="layui-btn layui-btn-xs layui-btn-{:$vo.state?'warm':'primary'}" href="javascript:;" data-confirm="确定操作该条数据吗？"
                    data-get='{:url("$classuri/change")}?id={$vo.id}&state={:abs($vo.state-1)}'>
                {:$vo.state?'禁用':'启用'}
            </button>
            {/if}
            {if auth("$classuri/del")}
            <button class="layui-btn layui-btn-xs" href="javascript:;"
               data-confirm="确定要删除吗！" data-get='{:url("$classuri/del")}?ids={$vo.id}'>
                删除
            </button>
            {/if}
        </td>
    </tr>
    {/volist}
    </tbody>
</table>
{$page|raw}
{/block}

{block name="script"}
<script src="__ADMIN__/js/browser-md5-file.min.js"></script>
<!--富文本编辑器-->
<script src="https://unpkg.com/wangeditor/release/wangEditor.min.js"></script>
<!--markdown编辑器-->
<link rel="stylesheet" href="__ADMIN__/lib/editor.md/css/editormd.min.css" />
<script src="__ADMIN__/lib/editor.md/editormd.min.js"></script>

<script>
    layui.form.render();
</script>
{/block}